FROM ubuntu:22.04

# 设为noninteractive模式来减少警告
ENV DEBIAN_FRONTEND=noninteractive

# 安装必要的软件, 可以根据自己的需求定制安装软件
RUN apt update -y && \
    apt -y install --no-install-recommends apt-utils dialog && \
    apt -y install \
    build-essential \
    clang \
    cmake \
    curl \
    g++ \
    gcc \
    git \
    iproute2 \
    ninja-build \
    pkg-config \
    poppler-utils \
    procps \
    python3 \
    python3-pip \
    sudo \
    tar \
    unzip \
    zip \
    && apt autoremove -y \
    && apt clean -y

# 添加用户的GID/UID必须与你本机用户的GID/UID匹配, 以免引起权限问题.
# 如果你本机的GID/UID与下面的设置(1000/1000)不一致, 请修改此文件.
# 参考: https://aka.ms/vscode-remote/containers/non-root-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG USER_NAME=vscode

# 创建一个非root用户
# 参考: https://aka.ms/vscode-remote/containers/non-root-user
RUN groupadd --gid $USER_GID $USER_NAME \
    && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USER_NAME \
    && echo $USER_NAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER_NAME \
    && chmod 0440 /etc/sudoers.d/$USER_NAME

# setup vcpkg
RUN git clone --depth=1 \
    --single-branch --branch=master \
    https://github.com/microsoft/vcpkg /home/$USER_NAME/vcpkg \
    && /home/$USER_NAME/vcpkg/bootstrap-vcpkg.sh \
    && /home/$USER_NAME/vcpkg/vcpkg integrate install \
    && /home/$USER_NAME/vcpkg/vcpkg install \
    fmt \
    gtest \
    RapidJSON \
    spdlog

# 切回到dialog模式
ENV DEBIAN_FRONTEND=dialog
USER $USER_NAME
